package com.candy.control;

import com.candy.service.LoginService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller
public class LoginController {
    @Autowired
    LoginService loginService;

    @RequestMapping("login")
    public String login(String username,String userpwd){
        System.out.println("控制层接收到前端发来的请求");
        System.out.println("username::::::"+username);
        System.out.println("userpwd::::::"+userpwd);
//        调用业务逻辑处理层，判断用户名密码是否匹配
        boolean ok=loginService.login(username,userpwd);
        if(ok){
//            用户名密码匹配，则跳转到/WEB-INF/pages/welcome.jsp页面
            return "welcome";
        }else {
//            若不匹配，则返回登录也
            return "../../login";
        }
    }
}
